<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
	<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
</head>
<body>
    <form method="post" action="https://www.baidu.com">
        <p><input type="checkbox" name="1" id="" value="1">尼古拉斯·赵四</p>
        <p><input type="checkbox" name="2" id="" value="2">莱昂纳多·刘能</p>
        <p><input type="checkbox" name="3" id="" value="3">约翰尼·宋小宝</p>
        <p><input type="checkbox" name="4" id="" value="4">布拉德·小沈阳</p>
		<input type='submit'>
	</form>
    <button onclick="selecefunction(0)">全选</button>
    <button onclick="selecefunction(1)">全不选</button>
    <button onclick="selecefunction(2)">反选</button>
    <script>
		function selecefunction(num){
			$('input').each(function(i, val){
				if(num <= 1){
					$(val).prop('checked', !num);
				}else{
					$(val).prop('checked', !val.checked);
				}
			});
		}
		
		

    </script>
</body>
</html>